<template>
    <div style="height: 100%">
        <el-drawer v-model="drawer" direction="rtl" size="400" close-on-press-escape>
            <template #header>
                <span style="font-weight: 1000">{{ $t('查询人员信息') }}</span>
            </template>
            <el-form :model="findform" label-width="100px">
                <el-row :gutter="10">
                    <div v-for="(item, index) in Stores.comui[componentId][0].baseProps">
                        <el-col v-if="item.visible" :span="24">
                            <el-form-item :label="I(item.label, item.labeleng)">
                                <template #default>
                                    <div v-if="item.type === 'date'">
                                        <el-date-picker v-model="findform[item.prop]" type="daterange" :start-placeholder="$t('开始')" :end-placeholder="$t('结束')" style="width: 200px" />
                                    </div>
                                    <div v-else-if="item.prop === 'tel'">
                                        <el-input-number v-model="findform[item.prop]" :controls="false" style="width: 200px"></el-input-number>
                                    </div>
                                    <div v-else-if="item.type === 'select'">
                                        <el-select v-model="findform[item.prop]" :id="item.prop" size="default" style="width: 200px">
                                            <el-option :label="$t('全部')" value="null" />
                                            <el-option :label="$t('在职')" value="在职" />
                                            <el-option :label="$t('离职')" value="离职" />
                                        </el-select>
                                    </div>
                                    <div v-else>
                                        <el-input v-model="findform[item.prop]" style="width: 200px" />
                                    </div>
                                </template>
                            </el-form-item>
                        </el-col>
                    </div>
                    <el-col :span="24">
                        <el-form-item>
                            <el-button color="#e1d8d8" round :icon="Refresh" @click="resetForm()" id="reset">{{ $t('重置') }}</el-button>
                            <el-button v-loading="loading" type="primary" round :icon="Search" @click="Getempdata()" id="find">{{ $t('查找') }}</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-drawer>
        <el-container style="height: 99.8%">
            <el-aside width="200px;height: 100%">
                <el-row style="padding: 10px; background: linear-gradient(89deg, rgb(56 162 249), rgb(155 255 255))" justify="space-between">
                    <el-col :span="10">
                        <span style="font-size: 20px; font-weight: 1000; color: white"
                            ><el-icon><HomeFilled /></el-icon>{{ $t('部门信息') }}</span
                        >
                    </el-col>
                </el-row>
                <el-card style="height: 94%; width: 99%">
                    <dept :isreadonly="true"></dept>
                </el-card>
            </el-aside>
            <el-main style="padding: 0; overflow: hidden">
                <el-row style="padding: 10px; background: linear-gradient(89deg, rgb(56 162 249), rgb(155 255 255))" justify="space-between">
                    <el-col :span="4">
                        <span style="font-size: 20px; font-weight: 1000; color: white"
                            ><el-icon><UserFilled /></el-icon>{{ $t('人员信息') }}</span
                        >
                    </el-col>
                    <el-col :span="20">
                        <div style="float: right">
                            <el-button v-loading="loading" type="primary" round :icon="Search" style="margin-left: 16px" @click="drawer = true"> {{ $t('更多查询') }} </el-button>
                            <UiSet :type="2" :index="0" :Prop="uiSectionList" :comid="componentId" v-model:isgrant="isuigrant" @before-click="uisetbefore"></UiSet>
                        </div>
                    </el-col>
                </el-row>
                <el-card>
                    <el-form :model="findform" :inline="true" label-width="100px">
                        <el-row :gutter="10">
                            <template v-for="(item, index) in Stores.comui[componentId][0].baseProps">
                                <el-col v-if="item.visible && item.ismore == false" :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
                                    <el-form-item :label="I(item.label, item.labeleng)">
                                        <template #default>
                                            <template v-if="item.type === 'date'">
                                                <el-date-picker v-model="findform[item.prop]" type="daterange" :start-placeholder="$t('开始')" :end-placeholder="$t('结束')" style="width: 200px" />
                                            </template>
                                            <template v-else-if="item.prop === 'tel'">
                                                <el-input-number v-model="findform[item.prop]" :controls="false" style="width: 200px"></el-input-number>
                                            </template>
                                            <template v-else-if="item.type === 'select'">
                                                <el-select v-model="findform[item.prop]" :id="item.prop" size="default" style="width: 200px">
                                                    <el-option :label="$t('全部')" value="null" />
                                                    <el-option :label="$t('在职')" value="在职" />
                                                    <el-option :label="$t('离职')" value="离职" />
                                                </el-select>
                                            </template>
                                            <template v-else>
                                                <el-input v-model="findform[item.prop]" style="width: 200px" />
                                            </template>
                                        </template>
                                    </el-form-item>
                                </el-col>
                            </template>
                            <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="8">
                                <el-form-item>
                                    <el-button color="#e1d8d8" round :icon="Refresh" @click="resetForm()" id="reset">{{ $t('重置') }}</el-button>
                                    <el-button v-loading="loading" type="primary" round :icon="Search" @click="Getempdata()" id="find">{{ $t('查找') }}</el-button>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-card>
                <el-card>
                    <el-row style="padding: 5px; background: linear-gradient(89deg, rgb(56 162 249), rgb(155 255 255))" justify="space-between">
                        <el-col :span="4">
                            <span style="font-size: 20px; font-weight: 1000; color: white">
                                <el-icon><Grid /></el-icon>{{ $t('列表数据') }}
                            </span>
                        </el-col>
                        <el-col :span="20">
                            <el-row justify="end" :gutter="10">
                                <el-button v-loading="loading" type="primary" :icon="Plus" round @click="addemp()">{{ $t('新增') }}</el-button>
                                <el-popconfirm :title="$t('确定要删除选中的人员吗?')" :confirm-button-text="$t('是')" :cancel-button-text="$t('否')" @confirm="deleteemp()" @cancel="canceldel()">
                                    <template #reference>
                                        <el-button v-loading="loading" type="danger" :icon="Delete" round style="margin-right: 10px">{{ $t('批量删除') }}</el-button>
                                    </template>
                                </el-popconfirm>
                                <excel ref="excelRef" :index="0" :Prop="uiSectionList" :comid="componentId" :title="$t('[人事档案]')" v-model:isgrant="isexcelgrant" @before-click="excelbefore" @comfirmimput="excelimputhandle"></excel>
                                <el-button v-loading="loading" color="#00b794" :icon="Document" round @click="exportEvent" style="margin-left: 10px">{{ $t('Excel导出') }} </el-button>
                                <UiSet :type="1" :index="0" :Prop="uiSectionList" :comid="componentId" v-model:isgrant="isuigrant" @before-click="uisetbefore"></UiSet>
                            </el-row>
                        </el-col>
                    </el-row>
                    <!-- prettier-ignore -->
                    <vxe-table
                        :data="empdata"
                         border 
                        :loading="loading" 
                        :max-height="tableMaxHeight"
                        :mouse-config="{selected: true}" 
                        :row-config="{ isCurrent: true, isHover: true }" 
                        :column-config="{resizable: true}"
                        :scroll-y="{enabled: true, gt: 0}"
                        :scroll-x="{enabled: true, gt: 100}"
                        show-overflow>
                         <vxe-column v-for="(column, index) in  Stores.comui[componentId][0].tableProps"
                        :field="column.prop" 
                        :width="column.width"
                        :fixed="column.fixed"
                        :align="column.align"
                        :visible="column.visible">
                        <template #header>
                            <div v-if="column.type === 'checkbox'">
                                    <el-checkbox v-model="Allcheck" @change="CheckAllChange" />
                                </div>
                                <div v-else>
                                    {{ I(column.label, column.labeleng) }}
                            </div>
                        </template>
                        <template #default="{ row,rowIndex  }">
                                <div v-if="column.type === 'checkbox'">
                                    <el-checkbox v-model="row['checked']" />
                                </div>
                                 <div v-else-if="column.type === 'action'">
                                    <el-button size="small" link @click="gotodetail(rowIndex, row)">
                                    <span style="font-size: 15px; color: #07a8d9">{{ $t('详情') }}</span>
                                    </el-button>
                                    <span style="margin: 2px">|</span>
                                    <el-popconfirm :title="$t('确定要删除选中的人员吗?')" :confirm-button-text="$t('是')" :cancel-button-text="$t('否')"  @confirm="deleteemp(row['id'])" >
                                        <template #reference>
                                            <el-button v-loading="loading" type="danger" size="small" link style="margin-right: 10px">
                                                <span style="font-size: 15px; color: red">{{ $t('删除') }}</span>
                                            </el-button>
                                        </template>
                                    </el-popconfirm>
                                </div>
                                <div v-else-if="column.prop === 'state'">
                                     <el-tag v-if="row.state === '在职'"  effect="dark" round type="primary" >{{$t(row[column.prop]) }}</el-tag>
                                     <el-tag v-if="row.state === '离职'"  effect="dark" round type="info" >{{$t(row[column.prop])}}</el-tag>
                                </div>
                                <div v-else-if="column.prop === 'isvirtualemp'">
                                     <el-tag v-if="row.isvirtualemp == 1"  effect="dark" round type="warning" >{{$t('是')}}</el-tag>
                                     <el-tag v-if="row.isvirtualemp != 1"  effect="dark" round type="primary" >{{$t('否') }}</el-tag>
                                </div>
                                <div v-else>
                                  {{ row[column.prop] }}
                                </div>
                        </template>
                        </vxe-column>
                        </vxe-table>
                        <pagemodel v-model:allcount="allcount" v-model:page="findform.page" v-model:pagecount="findform.pagecount" @pagechange="pagechange"></pagemodel>
                </el-card>
            </el-main>
        </el-container>
    </div>
</template>

<script lang="ts" setup>
//@ts-ignore
import { httpSend } from '@/utils/api';
import { useI18n } from 'vue-i18n';
import { getCurrentInstance, onMounted, ref, reactive, watch, onActivated, computed } from 'vue';
import { useRouter, onBeforeRouteLeave } from 'vue-router';
import type { VNode } from 'vue';
import { Setting, Refresh, Search, Document, Plus, Delete } from '@element-plus/icons-vue';
import * as XLSX from 'xlsx'; /*excel操作*/
/*组件*/
import deptmodel from '@/components/share/deptmodel.vue';
import dept from '@/components/share/dept.vue';
import UiSet from '@/components/share/UiSet.vue';
import excel from '@/components/share/excel.vue';
import pagemodel from '@/components/share/pagemodel.vue';
//@ts-ignore
import { TableUiSection } from '@/components/share/ui-set.interface.ts';
//@ts-ignore
import { usedeptStore, useshareStore } from '@/store'; /*pina管理*/
//@ts-ignore
import { formatDate, chkgrant } from '@/globalmethods'; /*通用方法*/
const excelRef = ref(null);
const { t } = useI18n(); //多语言
const isexcelgrant = ref(false);
const isuigrant = ref(false);
// 自定义字段配置
const componentId = 'empinfosetting';
const uiSectionList: TableUiSection[] = [
    {
        baseProps: [
            { label: '员工编号', prop: 'empid', visible: true, readonly: false, type: 'string', ismore: false },
            { label: '员工姓名', prop: 'empnm', visible: true, readonly: false, type: 'string', ismore: false },
            { label: '职务', prop: 'position', visible: true, readonly: false, type: 'string', ismore: true },
            { label: '入职日期', prop: 'entrydate', visible: true, readonly: false, type: 'date', ismore: true },
            { label: '电话', prop: 'tel', visible: true, readonly: false, type: 'number', ismore: true },
            { label: '在职状态', prop: 'state', visible: true, readonly: false, type: 'select', ismore: false },
        ],
        tableProps: [
            { label: '选择', labelex: '', labeleng: '', prop: 'checked', visible: true, readonly: false, width: '80', type: 'checkbox', fixed: 'left', align: 'center' },
            { label: '姓名', labelex: '', labeleng: '', prop: 'name', visible: true, readonly: false, width: '140', type: 'string', fixed: null, align: 'left' },
            { label: '英文名', labelex: '', labeleng: '', prop: 'englishname', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '性别', labelex: '', labeleng: '', prop: 'sex', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '部门编号', labelex: '', labeleng: '', prop: 'deptid', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '部门', labelex: '', labeleng: '', prop: 'deptnm', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '员工状态', labelex: '', labeleng: '', prop: 'state', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '员工编号', labelex: '', labeleng: '', prop: 'employeeid', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '员工编号1', labelex: '', labeleng: '', prop: 'employeeid1', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '员工卡号', labelex: '', labeleng: '', prop: 'iccardnumber', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '身份证号', labelex: '', labeleng: '', prop: 'idcard', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '虚拟员工', labelex: '', labeleng: '', prop: 'isvirtualemp', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '职务', labelex: '', labeleng: '', prop: 'position', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '工种', labelex: '', labeleng: '', prop: 'worktype', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '身高', labelex: '', labeleng: '', prop: 'height', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '体重', labelex: '', labeleng: '', prop: 'weight', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '年龄', labelex: '', labeleng: '', prop: 'age', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '学历', labelex: '', labeleng: '', prop: 'education', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '婚姻', labelex: '', labeleng: '', prop: 'married', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '电话', labelex: '', labeleng: '', prop: 'tel', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '出生日期', labelex: '', labeleng: '', prop: 'birthday', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '贯籍', labelex: '', labeleng: '', prop: 'addr', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '当前居住地', labelex: '', labeleng: '', prop: 'nowplace', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '邮箱', labelex: '', labeleng: '', prop: 'email', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: 'QQ号', labelex: '', labeleng: '', prop: 'qq', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '微信号', labelex: '', labeleng: '', prop: 'wechat', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '注册地址', labelex: '', labeleng: '', prop: 'registerplace', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '注册时间', labelex: '', labeleng: '', prop: 'registerdate', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '入职日期', labelex: '', labeleng: '', prop: 'enterdate', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '转正日期', labelex: '', labeleng: '', prop: 'confirmdate', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '离职日期', labelex: '', labeleng: '', prop: 'leavedate', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '离职原因', labelex: '', labeleng: '', prop: 'leavereason', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '离职备注', labelex: '', labeleng: '', prop: 'leavedes', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '紧急电话', labelex: '', labeleng: '', prop: 'emergenttel', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '紧急地址', labelex: '', labeleng: '', prop: 'emergentadress', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '编辑日期', labelex: '', labeleng: '', prop: 'editdate', visible: true, readonly: false, width: '100', type: 'date', fixed: null, align: 'center' },
            { label: '用户ID', labelex: '', labeleng: '', prop: 'userid', visible: true, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '图片1', labelex: '', labeleng: '', prop: 'picturepath1', visible: false, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '图片2', labelex: '', labeleng: '', prop: 'picturepath2', visible: false, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '图片3', labelex: '', labeleng: '', prop: 'picturepath3', visible: false, readonly: false, width: '100', type: 'string', fixed: null, align: 'center' },
            { label: '操作', labelex: '', labeleng: '', prop: 'action', visible: true, readonly: false, width: '200', type: 'action', fixed: 'right', align: 'center' },
        ],
    },
];

const Stores = useshareStore() as any;
Stores.setcomui([componentId, uiSectionList]);
const { appContext } = getCurrentInstance();
const ElMessage = appContext.config.globalProperties.$ElMessage;
const deptStore = usedeptStore() as any;

const router = useRouter();
const loading = ref(false);
const drawer = ref(false);
let empdata: any = ref([]);
const findform = reactive({
    dept: null,
    empid: null,
    empnm: null,
    position: null,
    entrydate: null,
    tel: null,
    state: 'null',
    page: 1,
    pagecount: 50,
});
const allcount = ref(0); // 总数据条数
//动态计算表格最大高度
const tableMaxHeight = computed(() => {
    return window.innerHeight - 350;
});

let isactive = true; //处理路由缓存组件的时候，在别的路由仍然触发了当前组件监控wtach事件
// 监听部门变化
watch(
    () => deptStore.deptid,
    (newData) => {
        if (isactive) {
            findform.dept = newData;
            Getempdata();
        }
    }
);
onActivated(() => {
    isactive = true;
});
onBeforeRouteLeave((to, from, next) => {
    // 在路由离开时停止watch
    isactive = false;
    next();
});

//初始化
onMounted(() => {
    //加载权限
    isexcelgrant.value=chkgrant('人事档案', 'excelimportemployee');
    isuigrant.value=chkgrant('人事档案', 'customset');
    getuiset();
    Getempdata();
});

const Allcheck = ref(false);
//表头全选/取消
const CheckAllChange = (val: boolean) => {
    empdata.value.forEach((v) => {
        v.checked = val;
    });
    empdata.value = [...empdata.value];
};

//获取配置数据
const getuiset = async () => {
    loading.value = true;
    let comdata = [];
    comdata[0] = componentId;
    comdata[1] = [];
    Object.assign(comdata[1], uiSectionList);
    const fd = new FormData();
    let data = { comid: componentId, userid: null };
    fd.append('param', JSON.stringify(data));
    const res = await httpSend('getComUiSet', fd, false);
    if (res && res.code == 1) {
        if (res.data.length > 0) {
            let data = JSON.parse(res.data[0]['setjson']);
            // 如果数据依然是字符串，则需要再解析一次
            if (typeof data === 'string') {
                data = JSON.parse(data); // 第二次解析
            }
            if (data) {
                Object.assign(comdata[1], data);
            }
        }
    }
    loading.value = false;
    Stores.setcomui(comdata);
};

//合计列统计
// const getSummaries = (param: any) => {
//     const { columns, data } = param;
//     //    console.log('columns',columns);
//     const sums: (string | VNode)[] = [];
//     columns.forEach((column, index) => {
//         if (index === 0) {
//             sums[index] = '合计';
//             return;
//         }
//         Stores.comui[componentId][0].tableProps.forEach((v) => {
//             if (column.property == v.prop && v.type == 'number') {
//                 const values = data.map((item) => Number(item[column.property]));
//                 console.log('columns', column.property);
//                 if (!values.every((value) => Number.isNaN(value))) {
//                     sums[index] = `${values.reduce((prev, curr) => {
//                         const value = Number(curr);
//                         if (!Number.isNaN(value)) {
//                             return prev + curr;
//                         } else {
//                             return prev;
//                         }
//                     }, 0)}`;
//                 } else {
//                     sums[index] = '';
//                 }
//             } else {
//                 return;
//             }
//         });
//     });
//     return sums;
// };

//查询数据
const Getempdata = async () => {
    if (!chkgrant('人事档案', 'getemployeelist')) {
        ElMessage.warning(t('您暂无查看权限,请联系管理员!'));
        return;
    }
    drawer.value = false;
    loading.value = true;
    const fd = new FormData();
    let data = findform;
    if (data.entrydate) {
        data['entrydatebe'] = formatDate(findform.entrydate[0], 'yyyy-MM-dd');
        data['entrydateend'] = formatDate(findform.entrydate[1], 'yyyy-MM-dd');
        delete data.entrydate;
    }
    fd.append('param', JSON.stringify(data));
    const res = await httpSend('getemployeelist', fd);
    if (res && res.code == 1 && res.data) {
        empdata.value = res.data.map((v) => {
            return {
                checked: false,
                ...v,
            };
        });
        allcount.value = res.count;
    }

    loading.value = false;
};
//重置
const resetForm = () => {
    for (let key in findform) {
        if (findform.hasOwnProperty(key)) {
            if (key == 'state') {
                findform[key] = 'null';
            } else if (key == 'page') {
                findform[key] = 1;
            } else if (key == 'pagecount') {
                findform[key] = 50;
            } else {
                findform[key] = null;
            }
        }
    }
    deptStore.setdeptform(null);
    deptStore.setdeptid(null);
    deptStore.setdeptnm(null);
};
//查看详情
const gotodetail = (index, row) => {
    if (!chkgrant('人事档案详情', 'getemployeedetail')) {
        ElMessage.warning(t('您暂无查看详情权限,请联系管理员!'));
        return;
    }
    router.push({ name: '人员信息详情', query: { empId: row.id } });
};
//新增
const addemp = () => {
    if (!chkgrant('人事档案', 'addbtn')) {
        ElMessage.warning(t('您暂无新增权限,请联系管理员!'));
        return;
    }
    router.push({ name: '人员信息详情', query: { empId: null } });
};

//导出
const exportEvent = () => {
    if (!chkgrant('人事档案', 'excelout')) {
        ElMessage.warning(t('您暂无导出权限,请联系管理员!'));
        return;
    }
    const formattedData = empdata.value.map((row) => {
        // 创建一个新的对象
        const newRow = {};
        Stores.comui[componentId][0].tableProps.forEach((v) => {
            if (v.visible && v.prop != 'action' && v.prop != 'checked') {
                newRow[v.label] = !!row[v.prop] ? row[v.prop] : '';
            }
        });
        return newRow; // 返回新创建的对象
    });
    // 使用自定义标题和数据生成工作表
    const ws = XLSX.utils.json_to_sheet(formattedData); // { header }
    // 创建一个新的工作簿
    const wb = XLSX.utils.book_new();
    // 将工作表添加到工作簿
    XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
    // 使用文件名导出 Excel 文件
    XLSX.writeFile(wb, t('人事档案导出') + '.xlsx');
};
//接收excel子组件传过来的数据并进行处理
const excelimputhandle = (data, iscover) => {
    let param = {
        iscover: iscover,
        data: data,
    };
    excelimport(param);
};
//excel导入
const excelimport = async (data) => {
    loading.value = true;
    const fd = new FormData();
    fd.append('param', JSON.stringify(data));
    const res = await httpSend('excelimportemployee', fd);
    if (res.code == 1) {
        excelRef.value?.closeform();
        Getempdata();
    }
    loading.value = false;
};

//删除勾选
const deleteemp = async (id = null) => {
    let idstr = null;
    if (id) {
        if (!chkgrant('人事档案', 'deleteemployee')) {
            ElMessage.warning(t('您暂无删除权限,请联系管理员!'));
            return;
        }
        idstr = id;
    } else {
        if (!chkgrant('人事档案', 'batchdel')) {
            ElMessage.warning(t('您暂无批量删除权限,请联系管理员!'));
            return;
        }
        idstr = empdata.value
            .filter((v) => v.checked)
            .map((item) => item.id)
            .join(',');
    }
    if (!idstr) {
        ElMessage.warning('请先选择需要删除的信息!');
        return;
    }
    loading.value = true;
    const fd = new FormData();
    fd.append('param', JSON.stringify({ id: idstr }));
    const res = await httpSend('deleteemployee', fd);
    if (res.code == 1) {
        Getempdata();
    }
    loading.value = false;
};
//页数变化重新查询
const pagechange=(e)=>{
    Getempdata();
}
//自定义配置权限判断
const uisetbefore = () => {
    if (!isuigrant.value) {
        ElMessage.warning(t('您暂无配置权限,请联系管理员!'));
        return;
    }
};
//excel导入前权限判断
const excelbefore = () => {
    if (!isexcelgrant.value) {
        ElMessage.warning(t('您暂无导入权限,请联系管理员!'));
        return;
    }
};
const I = (label, labeleng) => {
    if (labeleng && localStorage.getItem('locale') == 'en') {
        return labeleng;
    }
    return t(label);
};
</script>

<style scope>
.el-card__body {
    padding: 5px !important;
    color: #000000;
}
</style>
